<table id="user_userInfo_data"></table>
<script>
var uname="";
$(function(){
		var datagrid;
		var editRow=undefined;
		var op;
		var uname;
		datagrid=$('#user_userInfo_data').datagrid({   
		    url:'../uesrInfoServletBack',
		    queryParams:{uname:uname,op:"getUserInfo"}, 
		    loadMsg:'努力展开中...',
		    title:'会员列表',
		    iconCls:'icon-search',
		    fitColumns:true,
		    fit:true,
		    striped:true,
		    pagination:true,
		    rownumbers:true,
		    sortName:'usid',
		    sortOrder:'asc',
		    remoteSort:false,
		    pageNumber:1,
		    pageSize:10,
		   	pageList:[10,20,30,40,50],
		   	rowStyler: function(index,row){
				if (row.status==0){
					return 'background-color:orange;color:black;';
				}
			},
		    columns:[[   
		    	{field:'flag',title:'',checkbox:true,width:100,align:'center'},   
		        {field:'usid',title:'编号',width:100,align:'center',sortable:true},
		        {field:'email',title:'账号',width:150,align:'center',sortable:true}, 
		        {field:'uname',title:'昵称',width:100,align:'center',sortable:true}, 
		        {field:'sexs',title:'性别',width:50,align:'center',sortable:true},   	
		        {field:'tel',title:'联系方式',width:120,align:'center',sortable:true},    
		        {field:'udates',title:'注册时间',width:150,align:'center',sortable:true},      
		        {field:'statuss',title:'状态',width:80,align:'center',sortable:true},
		        {field:'_operate',title:'操作',width:80,align:'center',formatter:function(value,rowData,index){
					return "<a class='icon-file icon-padding'  href=\"javascript:showUserDetails('"+rowData+"')\">详细</a>"}
				}
		    ]],
		    toolbar: [{
				text:'删除',
				iconCls: 'icon-remove',
				handler: function(){
					var rows=$('#user_userInfo_data').datagrid("getChecked")[0];  	//获取所有被选中的行
					if(rows==undefined){
						$.messager.show({title:'温馨提示',msg:'请选择要删除的数据...',timeout:2000,showType:'slide'});
					}else{		
						$.messager.confirm('信息确认', '您确定要删除选中的记录吗?', function(r){
							if (r){
								op="delUserInfo";
								var usids="";
								var st=datagrid.datagrid("getSelections").length;
								for(var j=0;j<st-1;j++){
									usids+=datagrid.datagrid("getSelections")[j].usid+",";
								}
								usids+=datagrid.datagrid("getSelections")[j].usid;
								$.post("../uesrInfoServletBack?t="+new Date(),{op:"delUserInfo",usids:usids},function(data){
									data=parseInt($.trim(data));
									if(data>0){
										$.messager.show({title:'成功提示',msg:'会员信息删除成功...',timeout:3000,showType:'slide'});
										$('#user_userInfo_data').datagrid("reload");
									}else{
										$.messager.alert('失败提示','会员信息删除失败，请稍后重试...','error');
									}
								});
							}
						});
					}
				}
			},'-',{
		    	text:'撤销',
				iconCls: 'icon-redo',
				handler: function(){
					datagrid.datagrid("rejectChanges");
					datagrid.datagrid('endEdit', editRow );  //则关闭正在编辑的行
					editRow=undefined;
				}
			},'-',{
		    	text:'保存',
				iconCls: 'icon-save',
				handler: function(){
					datagrid.datagrid('endEdit',editRow);  //则关闭正在编辑的行
					var rows=datagrid.datagrid("getChanges")[0];
					if(rows==undefined){
						datagrid.datagrid("rejectChanges");
						datagrid.datagrid("unselectAll");
						editRow=undefined;
					}else{
						rows["op"]=op;
						$.post("../uesrInfoServletBack?t="+new Date(),rows,function(data){
							data=parseInt( $.trim(data) );
							if(data>0){
								$.msessager.show({title:'成功提示',msg:'会员信息添加成功...',timeout:3000,showType:'slide'});
							}else{
								$.messager.alert('失败提示','会员信息添加失败，请稍后重试...','error');
							}						
							rows=null;
							datagrid.datagrid("reload");
							editRow=undefined;
							datagrid.datagrid("rejectChanges");
							datagrid.datagrid("unselectAll");
						});
					}
					
				}
			},'-',{
				text:'<input id="ss" type="text" style="width:150px;margin:0px;padding:0px 2px;box-sizing:content-box" placeholder="请输入要搜索的值" />',
			},'-',{
				text:'搜索',
				iconCls: 'icon-search',
				handler: function(){
					var value=$.trim($("#ss").val());
					//查询数据重新填充表格
					datagrid.datagrid('load', {   
					    uname: value,
					    op:"getUserInfo"
					}); 

				}
			}]		       
		}); 


}) 

$("#user_userInfo_data").datagrid('getPager').pagination({
	beforePageText:'第',
	afterPageText:'页 共{pages}页',
	displayMsg:'当前显示{from}-{to} 条记录 共{total} 条记录'
})

</script>


<div id="UserInfo_data_show" class="easyui-dialog" title="会员信息" style="width:500px;height:450px"
	data-options="iconCls:'icon-edit',resizable:true,modal:true,closed:true,collapsible:true">
 	<br />
 		<form action="" style="padding-left:50px">
 			<label>会员编号:</label>&nbsp;<input id="user_usid" name="usid" style="width:100px" readOnly="readonly" /><br /><br />
 			<label>账　　号:</label>&nbsp;<input id="user_email" name="email" style="width:150px" readOnly="readonly" /><br /><br />
			<label>昵　　称:</label>&nbsp;<input id="user_uname" name="uname" style="width:150px" readOnly="readonly" /><br /><br />
			<label>真实姓名:</label>&nbsp;<input id="user_tname" name="tname" style="width:150px" readOnly="readonly" /><br /><br />
			<label>性　　别:</label>&nbsp;<input id="user_sex" name="sex" style="width:100px" readOnly="readonly" /><br /><br />
			<label>联系方式:</label>&nbsp;<input id="user_tel" name="tel" style="width:150px" readOnly="readonly" /><br /><br />
			<label>　QQ　:</label>&nbsp;&nbsp;<input id="user_QQ" name="QQ" style="width:150px" readOnly="readonly" /><br /><br />
			<label>身份证号:</label>&nbsp;<input id="user_idcard" name="idcard" style="width:200px" readOnly="readonly" /><br /><br />
			<label>家庭住址:</label>&nbsp;<input id="user_addr" name="addr" style="width:200px" readOnly="readonly" /><br /><br />
			<label>注册时间:</label>&nbsp;<input id="user_udate" name="udate" style="width:200px" readOnly="readonly" /><br /><br />
			<label style="color:red">更改状态:</label>&nbsp;
			<select id="user_status" name="status" style="width:100px">
			    <option value="1">可用</option>  
			    <option value="0">锁定</option>  
			</select><br /><br />
			<a href="javascript:closeDialog()" class="easyui-linkbutton" data-options="iconCls:'icon-ok'" style="float:right;margin-right:10px">确定</a>
 		</form>
</div> 


<script type="text/javascript">
	function showUserDetails(){
		$("#UserInfo_data_show").dialog("open");
		var rowData=$('#user_userInfo_data').datagrid("getSelected");
		$("#user_usid").val(rowData.usid);
		$("#user_email").val(rowData.email);
		$("#user_uname").val(rowData.uname);
		$("#user_tname").val(rowData.tname);
		$("#user_sex").val(rowData.sexs);
		$("#user_tel").val(rowData.tel);
		$("#user_QQ").val(rowData.QQ);
		$("#user_idcard").val(rowData.idcard);
		$("#user_addr").val(rowData.province + rowData.city + rowData.area);
		$("#user_udate").val(rowData.udate);
		$("#user_status").val(rowData.status);
	}
		
	function closeDialog(){
		var status=$("#user_status").val();
		var usid=$("#user_usid").val();
		$.post("../uesrInfoServletBack?t="+new Date(),{op:"updateUserStatus",status:status,usid:usid},function(data){
			data=parseInt($.trim(data));
			if(data>0){
				$.messager.show({title:'成功提示',msg:'状态更改成功...',timeout:3000,showType:'slide'});
				$("#UserInfo_data_show").dialog("close");
				$("#user_userInfo_data").datagrid("reload");
			}else{
				$.messager.alert('失败提示','状态更改失败，请稍后重试...','error');
			}
		});
	}
</script>




